<?php if (!defined('THINK_PATH')) exit();?><div class="bjui-pageContent">
    <form action="<?php echo U('save_attr');?>" data-callback="dialogFormCall" data-toggle="validate" data-alertmsg="false" class="dialogForm">
        <input type="hidden" name="id" value="<?php echo ($va["id"]); ?>"/>
        <div class="form-group">
            <label class="x100">属性名称:</label>
            <input type="text" name="name" data-rule="required" value="<?php echo ($va["name"]); ?>"/>
        </div>
        <!-- <div class="form-group">
            <label class="x100">所属商品分类:</label>
            <select name="category_id[]" data-toggle="selectpicker" multiple data-width="400">
                <option value="">--请选择--</option>
                <?php if(is_array($res)): $i = 0; $__LIST__ = $res;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$ro): $mod = ($i % 2 );++$i;?><option value="<?php echo ($ro["id"]); ?>" <?php if(in_array($ro['id'],$va['category_ids'])): ?>selected<?php endif; ?>><?php echo ($ro["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div> -->
        <div class="form-group">
            <label class="x100">检索:</label>
            <input type="radio" name="search" value="1" id="attr_search1" data-toggle="icheck" data-label="开启"  <?php if($va["search"] != '0'): ?>checked<?php endif; ?>  />
            <input type="radio" name="search" value="0" id="attr_search2" data-toggle="icheck" data-label="关闭"  <?php if($va["search"] == '0'): ?>checked<?php endif; ?> />
        </div>
        <div class="form-group">
            <label class="x100">录入方式:</label>
            <input type="radio" name="type" value="1" id="attr_addtype1" data-toggle="icheck" data-label="单选" <?php if($va["type"] == '1' or $va == null): ?>checked<?php endif; ?>/>
            <input type="radio" name="type" value="2" id="attr_addtype2" data-toggle="icheck" data-label="多选" <?php if($va["type"] == '2'): ?>checked<?php endif; ?>  />
            <input type="radio" name="type" value="3" id="attr_addtype3" data-toggle="icheck" data-label="下拉" <?php if($va["type"] == '3'): ?>checked<?php endif; ?>  />
            <input type="radio" name="type" value="4" id="attr_addtype4" data-toggle="icheck" data-label="文本"  <?php if($va["type"] == '4'): ?>checked<?php endif; ?>  />
            <input type="radio" name="type" value="5" id="attr_addtype5" data-toggle="icheck" data-label="多行文本" <?php if($va["type"] == '5'): ?>checked<?php endif; ?>  />
        </div>
        <div class="form-group">
            <label class="x100">可选值例表:</label>
            <input type="text" class="tagsu" data-tagname="value[]" data-toggle="tags" data-url="<?php echo U('Index/save');?>" data-width="400" size="15" placeholder="输入选项，回车提交">
        </div>
        <div class="form-group">
            <label class="x100">&nbsp;</label>
            <span class="text-warning">录入方式为"文本"或者"多行文本"时，此输入框不需填写</span>
        </div>
        <div class="form-group">
            <label class="x100">权重:</label>
            <input type="text" name="sort" data-toggle="spinner" data-min="0" data-step="1" data-rule="integer" class="w100" value="<?php echo ($va["sort"]); ?>" />
        </div>
    </form>
</div>
<script>

    $(function () {
        setTimeout(function () {
//            可选值列表 默认值
            var defaultTags = <?php echo ((isset($va["value"]) && ($va["value"] !== ""))?($va["value"]):"[]"); ?>,
                    tags = $('.bjui-tags');
            for (var i = 0 ; i < defaultTags.length; i++ ){
                tags.prepend('<span class="label label-tag" data-value="'+defaultTags[i]+'" style="margin-left: 1px; margin-top: 1px;"><i class="fa fa-tag"></i> '+defaultTags[i]+'&nbsp;&nbsp;<a href="#" class="close">×</a></span>');
                tags.append('<input type="hidden" name="value[]" value="'+defaultTags[i]+'">');
            }
            $('.label-tag', tags).find('a.close').click(function () {
               var p =  $(this).parents('.label-tag').attr('data-value');
                $(this).parents('.label-tag').remove();
                tags.find('input[type=hidden]').each(function (index, item) {
                    if( this.value == p ){
                        $(this).remove();
                    }
                })
            });
        });

    });
</script>

<div class="bjui-pageFooter">
		
	<?php if(save == save): ?><ul>
			<li><button type="submit" class="btn-default" data-icon="save">保存</button></li>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(save == close): ?>
	    <ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
	<?php elseif(save == page and $show != null): ?>
		<ul>
	        <li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
	    </ul>
		    <div class="pages">
		        <span>每页&nbsp;</span>
		        <div class="selectPagesize">
		            <select data-toggle="selectpicker" data-toggle-change="changepagesize">
		                <option value="<?php echo ($show['listrow']); ?>"><?php echo ($show['listrow']); ?></option>
		                <option value="60">60</option>
		                <option value="120">120</option>
		                <option value="150">150</option>
		            </select>
		        </div>
		        <span>&nbsp;条，共 <?php echo ($show['total']); ?> 条</span>
		    </div>
		    <div class="pagination-box" data-toggle="pagination" data-total="<?php echo ($show['total']); ?>" data-page-size="<?php echo ($show['listrow']); ?>" data-page-current="1">
		    </div>
	<?php elseif(save == page and $show == null): ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul>
	<?php else: ?>
		<ul>
			<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
		</ul><?php endif; ?>

</div>